package myky.com.doctorapp.ui

import android.view.View
import com.gyf.barlibrary.ImmersionBar
import kotlinx.android.synthetic.main.public_common_title.*
import myky.com.doctorapp.R
import myky.com.doctorapp.base.BaseActivity
import myky.com.doctorapp.contract.SuccessfulActivityContract
import myky.com.doctorapp.entity.DoctorEntity

import myky.com.doctorapp.presenter.SuccessfulActivityPresenter
import myky.com.doctorapp.utils.Constants
import myky.com.doctorapp.utils.DialogChoice

/**
 * Description:提交成功页面，是否授权弹窗
 * @author wuyangwuyang
 * Created by 2019/3/7 on 10:19
 */
class SuccessfulActivity :BaseActivity<SuccessfulActivityPresenter,String>(),SuccessfulActivityContract.View,DialogChoice.JurisdictionOnListener{


    var doctorId:Int=0
    override fun reloadActivity() {
    }

    override fun getPresenter(): SuccessfulActivityPresenter = SuccessfulActivityPresenter()
    override fun injectTarget(): View =findViewById(R.id.success_submit_lin)

    override fun initData() {
        val bundle=intent.extras
        doctorId=bundle.getInt(Constants.DOCTORID)
        mPresenter.pempower(doctorId)

        backLayout.setOnClickListener {

            onBackPressed()
        }
    }

    override fun initView() {
        ImmersionBar.with(this)
                .statusBarColor(R.color.colorPrimary)
                .titleBar(R.id.success_submit_title)
                .init()
        conmonTitleTextView.text = getText(R.string.success_submit)

    }

    override fun getContenView(): Int = R.layout.activity_successful
    override fun showDataSuccess(datas: String) {

        if(datas == "1"){
            mPresenter.getDoctorDeatails(doctorId.toString(),"v1.0")
        }
    }

    override fun showDoctorDeatails(doctorDeatails: DoctorEntity.PayLoadEntity) {

        DialogChoice.showJurisdiction(this,doctorDeatails,this)
    }

    override fun jurisdictionCallback(b: Boolean) {

        if(b){mPresenter.pEmpowerUpdate(doctorId)}
    }

    override fun showEmpowerUpdate(data: String) {
        showShortToast(getString(R.string.empowe_success))
    }

    override fun onBackPressed() {

        startActivity(MainActivity::class.java)
    }
}